Skip to content

Fix stale nonce in Zap two-step trade flows#790

Merged
realproject7 merged 2 commits intomainfrom
task/788-zap-nonce-fix
Apr 3, 2026
Merged

Fix stale nonce in Zap two-step trade flows#790
realproject7 merged 2 commits intomainfrom
task/788-zap-nonce-fix

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Adds 500ms delay after waitForTransactionReceipt in all three approve→write paths in TradingWidget.tsx
  • Fixes "nonce too low" error where writeContractAsync uses a stale cached nonce after an approval tx confirms

Affected Flows

  • Zap ERC-20 buy: approve → mint (line ~314)
  • PLOT buy: approve → mint (line ~344)
  • Sell: approve → burn (line ~378)

Test Plan

  • Execute a Zap buy with HUNT (requires approval) — verify mint succeeds after approval
  • Execute a PLOT buy requiring approval — verify mint succeeds
  • Execute a sell requiring approval — verify burn succeeds
  • Verify no regression when approval is already sufficient (skip path)

Fixes #788

🤖 Generated with Claude Code

Add 500ms delay after approval waitForTransactionReceipt in all three
approve→write paths (Zap ERC-20 buy, PLOT buy, sell). Gives the wallet
provider time to update its internal nonce before the second
writeContractAsync call, preventing "nonce too low" simulation failures.

Fixes #788

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 3, 2026 8:07am

Request Review

Instead of a hardcoded 500ms delay, wrap the post-approval
writeContractAsync calls in retryOnNonceError(). On first attempt,
if the wallet provider's nonce cache is stale, the nonce error is
caught and retried once after 500ms. No delay on fast providers;
reliable recovery on slow ones.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The change is minimal, focused, and it covers the three two-step approval flows implicated by the bug report. I did not find a code-level regression or a missed path in TradingWidget.tsx.

Findings

  • None.

Decision

Approved on code review. I did not wait for CI or runtime validation.

@realproject7 realproject7 merged commit aeacd02 into main Apr 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Zap trade fails after approval — stale nonce in writeContractAsync

2 participants